package com.x_memteor.base_master.bean.response;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.x_memteor.base_master.utils.MD5Utils;

/**
 * @author: X_Meteor
 * @description: 类描述
 * @version: V_1.0.0
 * @date: 2018/2/28 0028 下午 8:12
 * @company:
 * @email: lx802315@163.com
 */
public class TokenBean implements Parcelable {

    /**
     * token : ccce42af8ceeb7f9c77ef197e2ac8b9c
     * macid : 802
     * expires : 1519559561
     * server_time : 1519552361
     */

    private String token;
    private int macid;
    private int expires;
    private int server_time;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public int getMacid() {
        return macid;
    }

    public void setMacid(int macid) {
        this.macid = macid;
    }

    public int getExpires() {
        return expires;
    }

    public void setExpires(int expires) {
        this.expires = expires;
    }

    public int getServer_time() {
        return server_time;
    }

    public void setServer_time(int server_time) {
        this.server_time = server_time;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.token);
        dest.writeInt(this.macid);
        dest.writeInt(this.expires);
        dest.writeInt(this.server_time);
    }

    public TokenBean() {
    }

    protected TokenBean(Parcel in) {
        this.token = in.readString();
        this.macid = in.readInt();
        this.expires = in.readInt();
        this.server_time = in.readInt();
    }

    public static final Parcelable.Creator<TokenBean> CREATOR = new Parcelable.Creator<TokenBean>() {
        @Override
        public TokenBean createFromParcel(Parcel source) {
            return new TokenBean(source);
        }

        @Override
        public TokenBean[] newArray(int size) {
            return new TokenBean[size];
        }
    };

    public String getSign() {

        String sign = "";

        StringBuffer sb = new StringBuffer();
        sb.append("macid=");
        sb.append(macid);
        sb.append("&token=");
        sb.append(token);

        if (!TextUtils.isEmpty(sb)) {
            sign = MD5Utils.encryptMD5(sb.toString());
        }
        return sign;
    }
}
